package com.kyzh.core.pager.weal.share

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.gushenge.core.beans.ShareRecordBean
import com.gushenge.core.requests.WealRequest
import com.kyzh.core.R
import com.gushenge.core.base.activity.BaseActivity
import com.kyzh.core.databinding.ActSharerecordBinding
import com.kyzh.core.databinding.ItemSharerecordBinding

class ShareRecordActivity : BaseActivity() {
    companion object{
        @JvmStatic
        fun start(context: Context) {
            val starter = Intent(context, ShareRecordActivity::class.java)
            context.startActivity(starter)
        }
    }
    private lateinit var db : ActSharerecordBinding
    private val adapter = Adapter()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        db= DataBindingUtil.setContentView(this,R.layout.act_sharerecord)
        db.rev.adapter = adapter
        adapter.setEmptyView(R.layout.empty)
        initData()
    }

    private fun initData() {
        WealRequest.getShareRecord{
            adapter.setNewInstance(this)
        }
    }
    private inner class Adapter:BaseQuickAdapter<ShareRecordBean,BaseDataBindingHolder<ItemSharerecordBinding>>(
        R.layout.item_sharerecord) {
        override fun convert(
            holder: BaseDataBindingHolder<ItemSharerecordBinding>,
            item: ShareRecordBean
        ) {
            holder.dataBinding?.data = item
        }
    }
}